<?php

/**
 * A development-time set of functions.
 *
 * <p><strong>Note:</strong> This should be used for debugging purposes only,
 * any usage of the functions of this class should be deleted as soon as
 * debugging tasks get done.</p>
 *
 *
 * @author Virtualidad
 */
final class Dirty {

    private function __construct() {
        ;
    }

    private static function sabotageOnProduction() {
        $config = ModulesContext::instance()->getConfig();
        if (!$config->debug) {
            throw new Exception("Don't use the 'Dirty' class in a production enviroment!");
        }
    }

    /**
     * Prints a line using <br /> as line separator
     *
     * @param string $string
     */
    static function println($string = "") {
        self::sabotageOnProduction();

        echo $string . "<br />";
    }

    /**
     *
     * @param string $message = "" 
     */
    static function breakPoint($message = "") {
        self::sabotageOnProduction();

        echo $message;
        die;
    }

    static function dump($object, $output = true) {
        self::sabotageOnProduction();
        
        $result = "";
        ob_start();
        call_user_func('var_dump', $object);
        $result = ob_get_clean();

        if ($output) {
            echo $result;
        }

        return $result;
    }

}

?>
